<?php
require_once APPLICATION_PATH . '/forms/Auth/Login.php'; 
class AdminController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */
        $this->_authNamespace = new Zend_Session_Namespace('Zend_Auth');
    }

    public function indexAction() {
        if ($this->_authNamespace->userRole == 'admin') {
            $level = new Application_Model_LevelMapper();
            $levels = $level->fetchAll();

            //        $test = new Application_Model_TestMapper();
            //        $tests = $test->fetchAll();

            $questionnaire = new Application_Model_QuestionnaireMapper();
            $questionnaires = $questionnaire->fetchAll();

            $question = new Application_Model_QuestionMapper();
            $questions = $question->fetchAll();

            $testMapper = new Application_Model_QuestionMapper();
            $tests = $testMapper->fetchAll();

            $user = new Application_Model_UserMapper();
            $users = $user->fetchAll();

            $this->view->levels_count = count($levels);
            $this->view->tests_count = count($tests);
            $this->view->questionnaires_count = count($questionnaires);
            $this->view->questions_count = count($questions);
            $this->view->users_count = count($users);

            $db	= Zend_Db_Table_Abstract::getDefaultAdapter();
            $loginForm = new Application_Form_Auth();
            $this->view->loginForm = $loginForm;
        } else {
            return $this->_helper->redirector->gotoUrl('/auth/login');
        }
    }


}

